//
//  UserHomeHeadView.swift
//  甜言蜜语
//
//  Created by 王剑伟 on 16/6/14.
//  Copyright © 2016年 wl. All rights reserved.
//

import UIKit

class UserHomeHeadView: UIView {
   
    @IBOutlet weak var background: UIImageView!
    @IBOutlet weak var userIcon: UIImageView!
    @IBOutlet weak var focusNum: UILabel!
    @IBOutlet weak var followNum: UILabel!
    @IBOutlet weak var userID: UILabel!
    @IBOutlet weak var userSay: UILabel!
    @IBOutlet weak var followBtn: UIButton!
    @IBOutlet weak var fansBtn: UIButton!
    @IBOutlet weak var followOrCancelBtn: UIButton!
    var followOrCancel: Bool?
    var msg: regiestInfo?
    
    var model: UserHeadModel? {
        didSet {
            if model?.isMe == true{
                self.followOrCancelBtn.setTitle("设置", forState: UIControlState.Normal)
                self.followOrCancelBtn.setTitleColor(NAVIGATIONBAR_RED_COLOR, forState: UIControlState.Normal)
            }else{
                if model?.isguanzhu == true{
                    self.followOrCancelBtn.setImage(UIImage(named: "guanzhu_selected"), forState: UIControlState.Normal)
                }else{
                    self.followOrCancelBtn.setImage(UIImage(named: "guanzhu"), forState: UIControlState.Normal)
                }
            }
           
            self.background.sd_setImageWithURL(NSURL(string: (model?.backimg)!), placeholderImage: UIImage(named: "placeholder"))
            self.userIcon.sd_setImageWithURL(NSURL(string: (model?.timg)!), placeholderImage: UIImage(named: "placeholder"))
            self.focusNum.text = String((model?.guanzhunum)!)
            self.followNum.text = String((model?.fensinum)!)
            self.userID.text = model?.name
            self.userSay.text = model?.signature
        }
    }
    
    static func create() -> UserHomeHeadView {
        let view = NSBundle.mainBundle().loadNibNamed("UserHomeHeadView", owner: nil, options: nil).last as! UserHomeHeadView
        
        return view
    }
    
}
